#include <stdio.h>
#include "ofc/DSHA256.h"

int main(int argc, char *argv[])
{
  DSHA256 *sha1 = [DSHA256 alloc];
  DSHA256 *sha2 = [DSHA256 new  ];
  DText   *str;
  DData   *data;

  [sha1 init :"This is a test string for SHA256"]; // Init with a test string

  str = [sha1 hexdigest];              // Convert sha256 value to hexstring
  printf("SHA256 of \"This is a test string for SHA256\" in hex-string is:%s.\n", [str cstring]);
  [str free];


  [sha2 update :"abcdefghijklmnopqrstuvwxyz"]; // Feed the sha2 variable with a c-string
  [sha2 update :"0123456789" :10];     // Feed the sha2 variable with data string

  data = [sha2 digest];
  str  = [data toBase64];              // Get SHA256 value and convert to base 64
  printf("SHA256 of test string in base64 is:%s.\n", [str cstring]);
  [str  free];
  [data free];

  [sha1 free];                         // Cleanup
  [sha2 free];

  return 0;
}

